import createHeading from './heading.js'
import './main.css'
import icon from './icon.jpg'
import footerHtml from './footer.html'

const heading = createHeading()

document.body.appendChild(heading)

const img = new Image()
img.src = icon

document.body.append(img)

document.write(footerHtml)
// console.log1('heading')
// const ul = document.createElement('ul')
// document.body.append(ul)
// fetch('/api/users')
//     .then(res => res.json)
//     .then(data => {
//         console.log(data)
//         // data.forEach(item => {
//         //     const li = document.createElement('li')
//         //     li.textContent = item.login
//         //     unlink.append(li)
//         // })
//     })

let lastEdit = heading
module.hot.accept('./heading', () => {
  // console.log('header 模块更新了')

  const value = lastEdit.value
  document.body.removeChild(lastEdit)
  const newEdit = createHeading()
  newEdit.value = value
  document.body.appendChild(newEdit)
  lastEdit = newEdit
})
